package com.rtf.framework.common.util;

import com.rtf.framework.common.id.snowflake.AppIDGenerator;

/**
 * id生成工具
 *
 * @Author : liupeng
 * @Modified By
 */
public interface UtilId {

    AppIDGenerator ID_GENERATOR = new AppIDGenerator() ;

    /**
     * 按照默认的id生成规则生成id
     *
     * @return
     */
    static Long getNextId() {
        Long id = ID_GENERATOR.getNextId();
        while (id == null) {
            //如果id为空，随机生成一个字符
            try {
                Thread.currentThread().sleep( Double.valueOf(Math.random()*100).longValue());
            } catch (InterruptedException e) {
            }
            id = ID_GENERATOR.getNextId();
        }
        return id ;
    }

}
